package com.md.common.utils;

import org.springframework.core.env.Environment;

import java.io.UnsupportedEncodingException;

/**
 * 功能描述：获取从错误码配置文件中配置的属性值
 *
 * @author lujianping@oak168.com
 * @version 1.0
 * @date 2018-6-14 11:51
 * @since JDK 1.8
 */
public class ValueUtils {

    public static String value(String key) {
        String value = "";
        // 通过环境变量获取错误信息
        Environment environment = ApplicationContextProvider.getBean(Environment.class);
        try {
            value = new String(environment.getProperty(key, key).getBytes("ISO8859-1"), "UTF-8");
        } catch (UnsupportedEncodingException e) {

        }
        return value;
    }
}
